// get user info
import { page, deleteList, upCart, getAddress, addOrders } from '@/api/cart'

const actions = {
  // 这里是get商品信息
  getCart({ commit }, data) {
    return new Promise((resolve, reject) => {
      page(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getAddress({ commit }, data) {
    return new Promise((resolve, reject) => {
      getAddress(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  DeleteList({ commit }, data) {
    return new Promise((resolve, reject) => {
      deleteList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  // 修改购物车
  updateCart({ commit }, data) {
    return new Promise((resolve, reject) => {
      upCart(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  // 添加订单
  addOrder({ commit }, data) {
    return new Promise((resolve, reject) => {
      addOrders(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  actions
}
